package com.vote.www.service;

import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.vote.www.core.page.Pagination;
import com.vote.www.domain.Czjvoteorder;
import com.vote.www.domain.vo.VoteOreder;
import com.vote.www.persistence.CzjvoteorderMapper;
import com.vote.www.utils.UUIDUtils;




@Service("czjvoteorderService")
public class CzjvoteorderService {
	@Autowired
	private CzjvoteorderMapper czjvoteorderMapper;

	/**
	 * 查询某个czj_voteorder  车主节排序
	 * @param param
	 * @return
	 */
	public String getnickByuserinfoId(Map<String,Object> param) {
		return czjvoteorderMapper.getnickByuserinfoId(param);
	}
	
	/**
	 * 查询某个czj_voteorder  车主节排序
	 * @param param
	 * @return
	 */
	public Czjvoteorder getCzjvoteorder(Map<String,Object> param) {
		return czjvoteorderMapper.getCzjvoteorder(param);
	}	
	
	
	
	/**
	 * 查询某个czj_voteorder  车主节排序 通过投票当天日期
	 * @param param
	 * @return
	 */
	public Czjvoteorder getCzjvoteorderByvoteDate(Map<String,Object> param) {
		return czjvoteorderMapper.getCzjvoteorderByvoteDate(param);
	}	
	
	/**
	 * 查询某个czj_voteorder  获取上生最快的票数
	 * @param param
	 * @return
	 */
	public List<VoteOreder> getVoteOreder(Map<String,Object> param) {
		return czjvoteorderMapper.getVoteOreder(param);
	}	
   
	/**
	 * 查询czj_voteorder  车主节排序列表
	 * @return
	 */
	public Map<String,Object> getCzjvoteorderList(Map<String,Object> param) {
		Map<String,Object> returnMap = new HashMap<String,Object>();
		returnMap.put("totalCounts", czjvoteorderMapper.getTotalRows(param));
		returnMap.put("list", czjvoteorderMapper.getCzjvoteorderList(param));
		return returnMap;
	}
   
	/**
	 * 查询czj_voteorder  车主节排序列表
	 * @return
	 */
	public  Pagination getCzjvoteorderList(Map<String,Object> param,int pageSize,Integer pageNo,String order,String sort) {
		Pagination p = new Pagination();
		p.setPageNo(pageNo);
		p.setPageSize(pageSize);
		p.setOrder(order);
		p.setSort(sort);
		param.putAll(p.toMap());
		int count=czjvoteorderMapper.getTotalRows(param);
		List<Czjvoteorder> list=	czjvoteorderMapper.getCzjvoteorderList(param);
	
		p.setList(list);
		p.setTotalCount(count);
		return p;
		
	}
      
	/**
	 * 新增czj_voteorder  车主节排序
	 * @param czjvoteorder
	 * @param param
	 */
	@Transactional
	public void insertCzjvoteorder(Czjvoteorder czjvoteorder) {
		czjvoteorder.setVoteorderId(UUIDUtils.getUUID());
		czjvoteorderMapper.insertCzjvoteorder(czjvoteorder);
	}
   
	/**
	 * 编辑czj_voteorder  车主节排序
	 * @param czjvoteorder
	 * @param param
	 */
	@Transactional
	public void updateCzjvoteorder(Czjvoteorder czjvoteorder) {
		czjvoteorderMapper.updateCzjvoteorder(czjvoteorder);
	}
   
	/**
	 * 删除czj_voteorder  车主节排序
	 * @param param
	 */    
	@Transactional
	public void deleteCzjvoteorder(List<String> voteorderIdList) {
		for(String voteorderId: voteorderIdList){
	  		Map<String,Object> param = new HashMap<String,Object>();
	  		param.put("voteorderId", voteorderId);
	 	   czjvoteorderMapper.deleteCzjvoteorder(param);	  		
		}
	}


}